﻿using Prism.Commands;
using Prism.Events;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoneLineNew.Services.DB;
using ZoneLineNew.Services.Message;
using ZoneLineNew.ViewModelBase;

namespace ZoneLineNew.ViewModels.Dialogs {

    public class BatchPrintDialogViewModel : DialogViewModel {

        public BatchPrintDialogViewModel(
            IRegionManager regionManager,
            IDialogService dialog,
            IEventAggregator eventAggregator,
            IMessageService message,
            IDbOperate<IFreeSqlMainContext> mainDbOperate)
            : base(regionManager, dialog, eventAggregator, message, mainDbOperate) {


        }


        private int _printCount = 2;

        public int PrintCount {
            get { return _printCount; }
            set { _printCount = value; base.RaisePropertyChanged(); }
        }

        public DelegateCommand SaveCommand => new DelegateCommand(() => {
            if (PrintCount <= 0) {
                _message.Warning("打印数量必须大于1！");
                return;
            }
            DialogResult dialogResult = new DialogResult(ButtonResult.OK);
            dialogResult.Parameters.Add("PrintCount", PrintCount);
            base.OnDialogClosed(dialogResult);
        });

        public DelegateCommand CancelCommand => new DelegateCommand(() => {
            base.OnDialogClosed(ButtonResult.Cancel);
        });


        protected override void OnViewLoaded() {
            base.OnViewLoaded();
        }



    }

}
